package com.myhome.controller;


import com.myhome.entity.Department;
import com.myhome.entity.RespBean;
import com.myhome.service.IDepartmentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-09-04
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {
    @Autowired
    IDepartmentService departmentService;

    @ApiOperation(value = "查询所有部门")
    @GetMapping("/getalldepartments")
    public List<Department> getAllDepartments() {
        return departmentService.getAllDepartments();
    }

    @ApiOperation(value = "添加部门信息")
    @PostMapping("/add")
    public RespBean addDepartment(Department department) {
        return departmentService.addDepartment(department);
    }

    @ApiOperation(value = "删除部门")
    @DeleteMapping("/delete")
    public RespBean deleteDepartment(Integer id){
        return departmentService.deleteDepartment(id);
    }
}
